/* Copyright 1994 by Abacus Research and
 * Development, Inc.  All rights reserved.
 */

#if !defined (OMIT_RCSID_STRINGS)
char ROMlib_rcsid_vgatables[]
= "$Id: vgatables.c 63 2004-12-24 18:19:43Z ctm $";
#endif

#include "rsys/common.h"
#include "vgatables.h"

/* This table is used when extracting plane bits; the process of compacting
 * every 4th bit into a byte leaves them in a weird order, so this array
 * compensates for that and places them in the desired order.  It also
 * flips all of the bits.
 */
const unsigned char vga_planar_4bpp_unscramble[256] =
{
  0xFF, 0xBF, 0xFB, 0xBB, 0xEF, 0xAF, 0xEB, 0xAB, 0xFE, 0xBE, 0xFA,
  0xBA, 0xEE, 0xAE, 0xEA, 0xAA, 0x7F, 0x3F, 0x7B, 0x3B, 0x6F, 0x2F,
  0x6B, 0x2B, 0x7E, 0x3E, 0x7A, 0x3A, 0x6E, 0x2E, 0x6A, 0x2A, 0xF7,
  0xB7, 0xF3, 0xB3, 0xE7, 0xA7, 0xE3, 0xA3, 0xF6, 0xB6, 0xF2, 0xB2,
  0xE6, 0xA6, 0xE2, 0xA2, 0x77, 0x37, 0x73, 0x33, 0x67, 0x27, 0x63,
  0x23, 0x76, 0x36, 0x72, 0x32, 0x66, 0x26, 0x62, 0x22, 0xDF, 0x9F,
  0xDB, 0x9B, 0xCF, 0x8F, 0xCB, 0x8B, 0xDE, 0x9E, 0xDA, 0x9A, 0xCE,
  0x8E, 0xCA, 0x8A, 0x5F, 0x1F, 0x5B, 0x1B, 0x4F, 0x0F, 0x4B, 0x0B,
  0x5E, 0x1E, 0x5A, 0x1A, 0x4E, 0x0E, 0x4A, 0x0A, 0xD7, 0x97, 0xD3,
  0x93, 0xC7, 0x87, 0xC3, 0x83, 0xD6, 0x96, 0xD2, 0x92, 0xC6, 0x86,
  0xC2, 0x82, 0x57, 0x17, 0x53, 0x13, 0x47, 0x07, 0x43, 0x03, 0x56,
  0x16, 0x52, 0x12, 0x46, 0x06, 0x42, 0x02, 0xFD, 0xBD, 0xF9, 0xB9,
  0xED, 0xAD, 0xE9, 0xA9, 0xFC, 0xBC, 0xF8, 0xB8, 0xEC, 0xAC, 0xE8,
  0xA8, 0x7D, 0x3D, 0x79, 0x39, 0x6D, 0x2D, 0x69, 0x29, 0x7C, 0x3C,
  0x78, 0x38, 0x6C, 0x2C, 0x68, 0x28, 0xF5, 0xB5, 0xF1, 0xB1, 0xE5,
  0xA5, 0xE1, 0xA1, 0xF4, 0xB4, 0xF0, 0xB0, 0xE4, 0xA4, 0xE0, 0xA0,
  0x75, 0x35, 0x71, 0x31, 0x65, 0x25, 0x61, 0x21, 0x74, 0x34, 0x70,
  0x30, 0x64, 0x24, 0x60, 0x20, 0xDD, 0x9D, 0xD9, 0x99, 0xCD, 0x8D,
  0xC9, 0x89, 0xDC, 0x9C, 0xD8, 0x98, 0xCC, 0x8C, 0xC8, 0x88, 0x5D,
  0x1D, 0x59, 0x19, 0x4D, 0x0D, 0x49, 0x09, 0x5C, 0x1C, 0x58, 0x18,
  0x4C, 0x0C, 0x48, 0x08, 0xD5, 0x95, 0xD1, 0x91, 0xC5, 0x85, 0xC1,
  0x81, 0xD4, 0x94, 0xD0, 0x90, 0xC4, 0x84, 0xC0, 0x80, 0x55, 0x15,
  0x51, 0x11, 0x45, 0x05, 0x41, 0x01, 0x54, 0x14, 0x50, 0x10, 0x44,
  0x04, 0x40, 0x00,
};


/* This table is used when extracting plane bits; the process of compacting
 * every other bit into a byte leaves them in a weird order, so this array
 * compensates for that and places them in the desired order.  It also
 * flips all of the bits.
 */
const unsigned char vga_planar_2bpp_unscramble[256] =
{
  0xFF, 0xEF, 0xFE, 0xEE, 0xDF, 0xCF, 0xDE, 0xCE, 0xFD, 0xED, 0xFC,
  0xEC, 0xDD, 0xCD, 0xDC, 0xCC, 0xBF, 0xAF, 0xBE, 0xAE, 0x9F, 0x8F,
  0x9E, 0x8E, 0xBD, 0xAD, 0xBC, 0xAC, 0x9D, 0x8D, 0x9C, 0x8C, 0xFB,
  0xEB, 0xFA, 0xEA, 0xDB, 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 0x06, 0x35, 0x25, 0x34, 0x24,
  0x15, 0x05, 0x14, 0x04, 0x73, 0x63, 0x72, 0x62, 0x53, 0x43, 0x52,
  0x42, 0x71, 0x61, 0x70, 0x60, 0x51, 0x41, 0x50, 0x40, 0x33, 0x23,
  0x32, 0x22, 0x13, 0x03, 0x12, 0x02, 0x31, 0x21, 0x30, 0x20, 0x11,
  0x01, 0x10, 0x00,
};
